package com.sgj.observer;

/**
 * @Author: Guoji Shen
 * @Date: 2022/11/7 14:10
 */
public class App {

    public static void main(String[] args) {
        // 创建 Weather 对象
        Weather weather = new Weather();

        // 创建两个观察者对象
        CelsiusView celsiusView = new CelsiusView();
        WearView wearView = new WearView();

        // 让这两个观察者对象订阅目标对象 weather
        weather.attachObserver(celsiusView);
        weather.attachObserver(wearView);

        for (int i = 0; i < 10; i++) {
            // 获取新的天气数据，可能改变天气状态
            weather.fetchWeatherData();
            System.out.println("\n");
        }
    }
}